package praktikumid.w07.p3;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 
 * @author Aleksandr
 *
 */

public class RegExpTest {

	public static void main(String[] args) {
		Pattern p = Pattern.compile("name:\\s*([A-z]+)\\s+age:\\s*([0-9]{1,2})");
		String data = "id: 1 name: Joe age:27 id: 2 name: Mary age:22";
		Matcher m = p.matcher(data);
		
		while(m.find())
        {
            String name = m.group(1);
            String age = m.group(2);
            System.out.println ("Name: " + name + " Age: " + age);
        }
	}

}
